/**
 * ${tableComment} 表单
 *
 * @author motorfu
 * @email ffu@maxleap.com
 * @since ${date}
 */
import React from 'react';
import {
  Form, Input,
} from 'antd';

import Tools from '../../../../utils/tools';

const FormItem = Form.Item;

class ${moduleName}Form extends React.Component {
  constructor(props) {
    super(props);
    const hasItem = !Tools.isEmptyObj(props.itemData);
    this.state = {
      hasItem: hasItem,
    };
  }

  render() {
    const {hasItem} = this.state;
    const {
      form, itemData
    } = this.props;

    const {getFieldDecorator} = form;
    const formItemLayout = {
      labelCol: {
        span: 6
      },
      wrapperCol: {
        span: 16
      },
    };
    return (
        <Form>
          <#list columnList as column>
            <#if column.column_name != 'id'>
          <FormItem {...formItemLayout} label='${column.column_comment}'>
            {getFieldDecorator('${column.column_name}', {
              initialValue: hasItem ? itemData.${column.column_name} : null,
              rules: [{
                required: true, message: '请输入${column.column_comment}',
              }],
            })(
                <Input/>
            )}
          </FormItem>
            </#if>
          </#list>
        </Form>
    );
  }
}

${moduleName}Form.propTypes = {};
export default ${moduleName}Form;